package com.example.projecttest.service.impl;

import com.example.projecttest.mapper.EmpMapper;
import com.example.projecttest.poji.Emp;
import com.example.projecttest.poji.PageBean;
import com.example.projecttest.service.EmpService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class EmpServicelmpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;
//    @Override
//    public PageBean page1(Integer page, Integer pageSize) {
//        long count = empMapper.count();
//        Integer start =(page - 1) * pageSize;
//        List<Emp> page1 = empMapper.page(start, pageSize);
//        PageBean pageBean = new PageBean(count, page1);
//
//        return pageBean;
//    }
        @Override
    public PageBean page1(Integer page, Integer pageSize, String name, short gender, LocalDate begin, LocalDate end) {
            PageHelper.startPage(page,pageSize);
            List<Emp> list = empMapper.list(name,gender,begin,end);
            Page<Emp> p=(Page<Emp>)list;
            PageBean pageBean = new PageBean(p.getTotal(), p.getResult());

        return pageBean;
    }

}
